<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        /*TODO --1. 数据交换 */
        let a = 1,
            b = 2,
            c = 3,
            d = 4;

        // ES5写法
        var temp = a;
        a = b;
        b = temp;
        console.log(a, b);// 2 1

        //  ES6写法
        [c, d] = [d, c];
        console.log(c, d);// 4 3


        /*TODO --2. 提取JSON */
        let json = {
            id: 1,
            data: [1001, 1002],
            status: "ok"
        }
        //传统写法
        // var id = json.id,
        //     status = json.status,
        //     data = json.data;
        // console.log(id,status,data);
        
        // 对象解构赋值写法
        let {id, status, aa} = json;
        console.log(id, status, aa);// 1 "ok" undefined
    

        /*TODO --面试题: 如何快速提取JSON数据, 使用解构赋值 */

    </script>
</head>
<body>
    
</body>
</html>